import net.sf.json.JSONObject;


public class DifferentialDriveCommand {
	private double targetAngularSpeed;
	private double targetLinearSpeed;
	private DifferentialDriveProperties properties;
	
	public void setProperties(DifferentialDriveProperties properties) {
		this.properties = properties;
	}

	public DifferentialDriveCommand(double targetAngularSpeed,
			double targetLinearSpeed) {
		this.targetAngularSpeed = targetAngularSpeed;
		this.targetLinearSpeed = targetLinearSpeed;
	}

	public double getTargetAngularSpeed() {
		return targetAngularSpeed;
	}

	public void setTargetAngularSpeed(double targetAngularSpeed) {
		if(targetAngularSpeed <= properties.getMaxAngularSpeed())
			this.targetAngularSpeed = targetAngularSpeed;
		else
			this.targetAngularSpeed = properties.getMaxAngularSpeed();
	}

	public double getTargetLinearSpeed() {
		return targetLinearSpeed;
	}

	public void setTargetLinearSpeed(double targetLinearSpeed) {
		if(targetLinearSpeed <= properties.getMaxLinearSpeed())
			this.targetLinearSpeed = targetLinearSpeed;
		else
			this.targetLinearSpeed = properties.getMaxLinearSpeed();
	}
	
	public JSONObject toJSONObject(){
		JSONObject obj = new JSONObject();
		obj.accumulate("TargetAngularSpeed", targetAngularSpeed);
		obj.accumulate("TargetLinearSpeed", targetLinearSpeed);
		return obj;
	}
	
}
